package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-23 00:57
 */
public class FlipAndInvertImage {
    public int[][] flipAndInvertImage(int[][] image) {

        for (int i = 0; i < image.length; i++) {
            image[i] = reserve(back(image[i]));
        }
        return image;
    }

    private int[] reserve(int[] back) {
        for (int i = 0; i < back.length; i++) {
            back[i] = back[i] == 0 ? 1 : 0;
        }
        return back;
    }

    private int[] back(int[] ints) {
        for (int i = 0, j = ints.length - 1; i < j; i++, j--) {
            int temp = ints[i];
            ints[i] = ints[j];
            ints[j] = temp;
        }
        return ints;
    }
}
